wayland: Implement asking for a GLES context
authorEmmanuele Bassi <ebassi@gnome.org>
Mon, 18 Apr 2016 09:13:05 +0000 (10:13 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Mon, 25 Apr 2016 11:29:37 +0000 (12:29 +0100)
Wayland uses EGL, which allows us to ask for a GLES context.

https://bugzilla.gnome.org/show_bug.cgi?id=743746

gdk/wayland/gdkglcontext-wayland.c

index b578d7a191d3d43d949052e046963d22e25cc26a..1519e1ac8d4dc8af0ce1da72695ecdbe1a23cc7b 100644 (file)
@@ -114,7 +114,7 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
   EGLContext ctx;
   EGLint context_attribs[N_EGL_ATTRS];
   int major, minor, flags;
-  gboolean debug_bit, forward_bit, legacy_bit;
+  gboolean debug_bit, forward_bit, legacy_bit, use_es;
   int i = 0;
 
   gdk_gl_context_get_required_version (context, &major, &minor);
@@ -122,6 +122,7 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
   forward_bit = gdk_gl_context_get_forward_compatible (context);
   legacy_bit = (_gdk_gl_flags & GDK_GL_LEGACY) != 0 ||
                (share != NULL && gdk_gl_context_is_legacy (share));
+  use_es = gdk_gl_context_get_use_es (context);
 
   flags = 0;
 
@@ -130,17 +131,28 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
   if (forward_bit)
     flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
 
-  /* We want a core profile, unless in legacy mode */
-  context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
-  context_attribs[i++] = legacy_bit
-                       ? EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR
-                       : EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
-
-  /* Specify the version */
-  context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
-  context_attribs[i++] = legacy_bit ? 3 : major;
-  context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
-  context_attribs[i++] = legacy_bit ? 0 : minor;
+  if (!use_es)
+    {
+      /* We want a core profile, unless in legacy mode */
+      context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+      context_attribs[i++] = legacy_bit
+                           ? EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR
+                           : EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+
+      /* Specify the version */
+      context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
+      context_attribs[i++] = legacy_bit ? 3 : major;
+      context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
+      context_attribs[i++] = legacy_bit ? 0 : minor;
+    }
+  else
+    {
+      context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
+      if (major == 3)
+        context_attribs[i++] = 3;
+      else
+        context_attribs[i++] = 2;
+    }
 
   /* Specify the flags */
   context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;